/*-------------------------------------------------------------------------*/
/**
  @file		structures.h
  @author	Renaud Wanschoor
  @date	july 2004
  @version	$Revision: 2.7 $
  @brief	plib typedef structures
  
*/
/*--------------------------------------------------------------------------*/

/***********************************************
 ***********************************************
 **                                           **
 **                md_io.h                    **
 **                                           **
 ***********************************************
 ***********************************************/
/**
 * \brief command line control structure
 *
 * is used to store information from the command line when
 * the partitioner is ran
 *
 */
typedef struct IoCtrl{
  int WType; 		/**< edge weight type (for the uncoarsening phase) */
  int CType; 		/**< matching scheme */
  int RType; 		/**< uncoarsening method */
  int out[3]; 		/**< information about output out[IO_RESULT] for multiple output (multiple run with the same graph and grid),
			 * out[IO_ID] id of the run (when there are multiple run), out[IO_SER] what should be done concerning serial file (
			 * serialize, unserialize, nothing) */
  int debug; 		/**< debug level (unused ??)*/
  int PSeed; 		/**< program random seed */
  int CSeed; 		/**< coarsening random seed */
  int ISeed; 		/**< initial partitioning seed */
  int RSeed; 		/**< uncoasening seed */
  int dbglvl;		/**< debuglvl */
  int preference; 	/**< boundary preference (unused??) */
  int NBytes;              /**< how many bytes to send for each vertex, default is 10 */

  /* funny pagrid options 0 if not modified by arguments or value if changed */
  int et;
  int im;
  int tol;
  int flow;
  int bal;
  int quad;		/**< quadratic path length in the cost function: 0 (not use); 1 (use)*/

  char F_output[256]; 	/**< output filename base (things are going to be appended to this for output files */
  char *F_graph; 	/**< graph file path */
  char *F_grid;		/**< grid file path */
  char F_serialize[256];/**< serialize file path */
}IoCtrl;

/***********************************************
 ***********************************************
 **                                           **
 **                pqueue.h                   **
 **                                           **
 ***********************************************
 ***********************************************/
/**
 * \brief memory management structure
 */
typedef struct Mem{
  size_t    max_s;	/**< maximum size of all heaps */
  size_t    s;		/**< current usage of heaps memory */
  void*     mem;	/**< where memory is allocated */
}Mem;

/**
 * \brief priority queues structure
 */
typedef struct Heap{
  int  	    type;	/**< heap type */
  Mem*      farm;	/**< farm to request memory */
  void*     mem;	/**< pointer to first inserted element */

  int  	    s;		/**< heap size */
  int       max_s;   	/**< maximum size of heap */

  void 	    **pos;	/**< pos[i] is the pos of edge or vertex i in the heap */
  void      *h;		/**< heap depending on implementation */

}Heap;

/**
 * \brief graph structure (for pagridplot and common tools functions (like those in md_io.c)
 */
typedef struct  plotgraphdef {

  Mem mem;		/**< pointer where memory is allocated */

  /**********************
   * graph information
   *********************/
  int wgtflag;		/**< whether the vertics are weighted*/
  int ncon;		/**< The # of constrains */

  int nvtxs, nedges;	/**< The # of vertices and edges in the graph */
  int *adjidx;		/**< Pointers to the locally stored vertices */
  int *vwgt;		/**< Vertex weights */
  int *adjncy;		/**< adjacency lists of nvtxs */
  int *adjwgt;		/**< weights of the adjacency lists */
  int *adjwgtsum;	/**< The sum of the adjacency weight of each vertex */
  
  /***********************
   * Matching information
   **********************/
  int *map;		/**<label with which a vertex is matched */
  int *match;
  
  /**************************
   * Refinement information
   *************************/
  int *pro;		/**<Array holding the assigned processor to a vertex*/

  /**************************
   * level browsing
   *************************/
  
  struct plotgraphdef *child;	/**<pointer to child (coarser) graph*/
  struct plotgraphdef *father;	/**<pointer to father (finer) graph*/

}PlotGraphType;

/**
 * \brief grid structure for pagridplot and common tool functions (like those in md_io.c)
 */
typedef struct plotgriddef {		/*computationtional grid information*/
  int npro;			/**<Number of processors*/
  int nedges;			/**<Number of links*/

  Mem     mem;

  double** ratio;		/**< Ratio (Tcomm/Tcomp) matrix*/
  double*  exec;                 /**< array of processors execution time */

  /**********************************/
  /* initial values of the ratio    */
  /**********************************/
  int      r_from;
  int      r_to;
  double   r_val;

  /******************/
  /** -- REMOVE -- **/
  int**    netcost;		/**<Real Network Cost matrix*/
  double*  proratio;		/**<Execution time Ratio for each processors*/
  double*  proportion;		/**<Processor weighting for each processors*/
  double*  prospeed;             /**< 1/proportion */
  int*     penalty;			/**<penalty weight for each processors*/
  int**    connect;
  int**    latency1;
  /** -- END REMOVE -- **/
  /**********************/
}PlotGridType;
